<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>自定义指令固定参数</title>
</head>
<body>
<div id="app">
    <div v-pin="200">在距离顶部 200 像素的位置显示</div>
    <div v-pin="top">在距离顶部 500 像素的位置显示</div>
</div>

<script !src="" type="module">
    import {createApp, ref} from "../../../../js/vue.esm-browser.js";

    let app = createApp({
        setup() {
            let top = 500
            return {
                top
            }
        }
    })

    app.directive(
        "pin",
        {
            mounted(el, binding){
                el.style.position = "fixed"
                el.style.top =  binding.value + "px"
            }
        }
    )

    app.mount("#app")
</script>
</body>
</html>